home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / Meshwriter / ConverterTest / converter.c next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  3.8 KB  |  98 lines

  1. /*
  2. ** ANSI standart includes
  3. */
  4. #include <stdio.h>
  5.  
  6. /*
  7. ** Amiga includes
  8. */
  9.  
  10. /*
  11. ** Amiga libraries includes
  12. */
  13.  
  14. /*
  15. ** Project includes
  16. */
  17. #include </meshlib.h>
  18.  
  19. /************************** test main *******************************/
  20. void main(void) {
  21.   ULONG mesh,mat1,mat2;
  22.   TOCLColor color;
  23.   TOCLVertex coords[6];
  24.   ULONG ret,index,i;
  25.   ULONG indexes[6];
  26.     
  27.   if((mesh = MWLMeshNew())!=0) {
  28.     printf("Object created\n");
  29.  
  30.  
  31.     if((MWLMeshMaterialAdd(mesh,&mat1))!=RCNOERROR) {
  32.       printf("Could not create a new material\n");
  33.     }
  34.     color.r=255,color.g=0,color.b=0;
  35.     MWLMeshMaterialAmbientColorSet(mesh,mat1,&color);
  36.     MWLMeshMaterialNameSet(mesh,mat1,"rot");
  37.     MWLMeshMaterialShininessSet(mesh,mat1,1);
  38.     MWLMeshMaterialTransparencySet(mesh,mat1,0);
  39.     printf("Material created\n");
  40.  
  41.     if((MWLMeshMaterialAdd(mesh,&mat2))!=RCNOERROR) {
  42.       printf("Could not create a new material\n");
  43.     }
  44.     color.r=0,color.g=0,color.b=255;
  45.     MWLMeshMaterialAmbientColorSet(mesh,mat2,&color);
  46.     MWLMeshMaterialNameSet(mesh,mat2,"blau");
  47.     MWLMeshMaterialShininessSet(mesh,mat2,1);
  48.     MWLMeshMaterialTransparencySet(mesh,mat2,0);
  49.     printf("Material created\n");
  50.  
  51.     if(MWLMeshNameSet(mesh,"Converter test")) printf("Name not set\n");
  52.     else printf("Name set\n");
  53.  
  54.     coords[0].x=-10,coords[0].y=-10,coords[0].z=0;
  55.     coords[1].x=10,coords[1].y=10,coords[1].z=0;
  56.     coords[2].x=-10,coords[2].y=10,coords[2].z=0;
  57.     coords[3].x=-10,coords[3].y=-10,coords[3].z=0;
  58.     coords[4].x=10,coords[4].y=-10,coords[4].z=0;
  59.     coords[5].x=10,coords[5].y=10,coords[5].z=0;
  60.  
  61.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[0]),&(indexes[0])),coords[0].x,coords[0].y,coords[0].z);
  62.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[1]),&(indexes[1])),coords[1].x,coords[1].y,coords[1].z);
  63.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[2]),&(indexes[2])),coords[2].x,coords[2].y,coords[2].z);
  64.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[3]),&(indexes[3])),coords[3].x,coords[3].y,coords[3].z);
  65.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[4]),&(indexes[4])),coords[4].x,coords[4].y,coords[4].z);
  66.     printf("Vertex added %ld / %f %f %f\n",MWLMeshVertexAdd(mesh,&(coords[5]),&(indexes[5])),coords[5].x,coords[5].y,coords[5].z);
  67.  
  68.     printf("Index list :position / index\n");
  69.     for(i=0;i<6;i++) printf("%ld / %ld\n",i,indexes[i]);
  70.  
  71.     printf("Research coordinates with indexes : retval / coordinates / index\n");
  72.     for(i=0;i<6;i++) {
  73.         printf("%ld / %f %f %f ",MWLMeshVertexIndexGet(mesh,&(coords[i]),&index),coords[i].x,coords[i].y,coords[i].z);
  74.         printf("%ld\n",index);
  75.     }
  76.  
  77.     printf("Polygon added %ld\n",MWLMeshPolygonAdd(mesh,mat1));
  78.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[0]));
  79.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[1]));
  80.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[2]));
  81.  
  82.     printf("Polygon added %ld\n",MWLMeshPolygonAdd(mesh,mat2));
  83.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[3]));
  84.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[4]));
  85.     printf("Vertex assigned %ld\n",MWLMeshPolygonVertexAssign(mesh,indexes[5]));
  86.  
  87.     printf("Total number of vertices : %ld\n",MWLMeshNumberOfVerticesGet(mesh));
  88.     printf("Total number of polygons : %ld\n",MWLMeshNumberOfPolygonsGet(mesh));
  89.     printf("Total number of materials : %ld\n",MWLMeshNumberOfMaterialsGet(mesh));
  90.     
  91.     printf("Triangles added\n");
  92.     if((ret=MWLMeshSave3D(mesh,T3DFGEOA,"ram:pout.geo",NULL))) printf("Object not saved : %ld\n",ret);
  93. //    if((ret=MWLMeshSave2D(mesh,T2DFPSP,"ram:pout.ps",TVWTOP,TDMPOINTS,NULL))) printf("Object not saved : %ld\n",ret);
  94.  
  95.     printf("Deleting mesh\n");
  96.     MWLMeshDelete(mesh);
  97.   }
  98. }